/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tpdisenio2009.mvp.display;

import java.util.List;
import javax.swing.table.AbstractTableModel;
import tpdisenio2009.model.beans.SoccerPlayer;

/**
 *
 * @author Pablito
 */
public class CreateFantasyTeamTableModel extends AbstractTableModel {

    private final List<SoccerPlayer> soccerPlayers;
    private static final int COLUMN_COUNT = 4;

    public CreateFantasyTeamTableModel(List<SoccerPlayer> players) {
        soccerPlayers = players;
    }

    public SoccerPlayer getSoccerPlayer(int row) {
        if (row < 0 || row >= soccerPlayers.size())
            return null;
        return soccerPlayers.get(row);
    }

    public int getRowCount() {
        return soccerPlayers.size();
    }

    public int getColumnCount() {
        return COLUMN_COUNT;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        try {
            SoccerPlayer player = soccerPlayers.get(rowIndex);
            switch (columnIndex) {
                case 1:
                    return player.getLastName() + ", " + player.getFirstName();
                case 2:
                    return player.getRealTeam().getName();
                case 3:
                    return String.valueOf( player.getPrice() );
            }
        } catch (Exception e) {
        }
        return null;
    }
}